<include file="Public/header" />
<title>我的桌面</title>
</head>
<body>
<div class="pd-20">

		<table class="table table-border table-bordered table-hover table-bg" style="margin-top:20px;">
		<thead>
			<tr>
				<th scope="col" colspan="28">产品列表</th>
			</tr>
			<tr class="text-c">
				<th width="40">ID</th>
				<th width="40">单号</th>
				<th width="40">申请部门</th>
				<th width="100">批次</th>
				<th width="40">申请人</th>
				<th width="40">制单人</th>
				<th width="40">入库仓库</th>
				<th width="40">产品名称</th>
				<th width="40">产品规格</th>
				<th width="40">料号</th>
				<th width="40">产品编码</th>
				<th width="40">计划数量</th>
				<th width="40">主单位</th>
				<th width="40">生产周期要求</th>
				<th width="40">申请摘要</th>
				<th width="40">账册编码</th>
				<th width="40">条形码</th>
				<th width="40">完成数量</th>
				<th width="40">实际入库数量</th>
				<th width="40">合格品数量</th>
				<th width="40">残次品数量</th>
				<th width="40">报废品数量</th>
				<th width="40">入库成本单价</th>
				<th width="40">销售单价(含税)</th>
				<th width="40">出厂价</th>
				<th width="40">过期时间</th>
				<th width="40">生产时间</th>
				<th width="40">备注</th>
			</tr>
		</thead>
		<tbody>
			<tr class="text-c">
				<td><{$detail.id}><input type="hidden"   name="list_id" value="<{$detail.id}>" ></td>
				<td><{$detail.purchasing_no}></td>
				<td>
					<volist name="section_list" id="vo">
							<if condition="$vo['no'] eq $detail['section_no']"><{$vo.name}></if>
						</volist>
				</td>
				<td><{$detail.batch_no}></td>
				<td>
					<volist name="personnel_list" id="vo">
							<if condition="$vo['no'] eq $detail['people_purchasing_no']"><{$vo.name}></if>
						</volist>
				</td>
				<td>
					<volist name="personnel_list" id="vo">
								<if condition="$vo['no'] eq $detail['people_make_no']"><{$vo.name}></if>
							</volist>
				</td>
				<td>
					<volist name="warehouse_list" id="vo">
								<if condition="$vo['warehouse_code'] eq $detail['inbound_warehouse_code']"><{$vo.name}></if>
							</volist>
				</td>
				<td><{$detail.pro_name}></td>
				<td><{$detail.pro_spec}></td>
				<td><{$detail.source_no}></td>
				<td><{$detail.pro_no}></td>
				<td><{$detail.pro_num_plan}></td>
				<td>
				<volist name="unit_list" id="vo">
									<if condition="$vo['unit_no'] eq $detail['unit1']"><{$vo.unit_name}></if>
								</volist>
				</td>
				<td><{$detail.product_weeks}></td>
				<td><{$detail.product_marks}></td>
				<td><input type="text" class="input-text"  placeholder="账册编码" id="manua_id" name="manua_id"  value="<{$detail.manua_id}>" ></td>
				<td><input type="text" class="input-text"  placeholder="条形码" id="bar_code" name="bar_code"  value="<{$detail.bar_code}>" ></td>
				<td><input type="text" class="input-text"  placeholder="完成数量" id="pro_num" name="pro_num"  value="<{$detail.pro_num}>" ></td>
				<td><input type="text" class="input-text"  placeholder="实际入库数量" id="inbound_num" name="inbound_num"  value="<{$detail.inbound_num}>" ></td>
				<td><input type="text" class="input-text"  placeholder="合格品数量" id="conforming_p_num" name="conforming_p_num"  value="<{$detail.conforming_p_num}>" ></td>
				<td><input type="text" class="input-text"  placeholder="残次品数量" id="nonconforming_p_num" name="nonconforming_p_num"  value="<{$detail.nonconforming_p_num}>" ></td>
				<td><input type="text" class="input-text"  placeholder="报废品数量" id="scrap_one_num" name="scrap_one_num"  value="<{$detail.scrap_one_num}>" ></td>
				<td><input type="text" class="input-text"  placeholder="入库成本单价" id="inbound_price" name="inbound_price"  value="<{$detail.inbound_price}>" ></td>
				<td><input type="text" class="input-text"  placeholder="销售单价(含税)" id="sell_price" name="sell_price"  value="<{$detail.sell_price}>" ></td>
				<td><input type="text" class="input-text"  placeholder="出厂价" id="factory_price" name="factory_price"  value="<{$detail.factory_price}>" ></td>
				<td><input type="input-text" name="overdue_time" onfocus="WdatePicker({el:$dp.$('d12')})" id="overdue_time" class="input-text Wdate" style="width:120px;" value="<{$detail.overdue_time|date='Y-m-d',###}>"  placeholder="过期时间"></td>
				<td><input type="input-text" name="factory_time" onfocus="WdatePicker({el:$dp.$('d12')})" id="factory_time" class="input-text Wdate" style="width:120px;" value="<{$detail.factory_time|date='Y-m-d',###}>"  placeholder="生产时间"></td>
				<td><{$detail.mark}></td>
			</tr>
			<volist name="byproduct_list" id="vs">
				<tr class="text-c">
				<td><{$vs.id}>副<input type="hidden"   name="list_id" value="<{$vs.id}>" ></td>
				<td><{$detail.purchasing_no}></td>
				<td>

						<volist name="section_list" id="vo">
							<if condition="$vo['no'] eq $detail['section_no']"><{$vo.name}></if>
						</volist>
					</select>
				</td>
				<td><{$detail.batch_no}></td>
				<td>
						<volist name="personnel_list" id="vo">
							<if condition="$vo['no'] eq $detail['people_purchasing_no']"><{$vo.name}></if>
						</volist>
				</td>
				<td>
							<volist name="personnel_list" id="vo">
								<if condition="$vo['no'] eq $detail['people_make_no']"><{$vo.name}></if>
							</volist>
				</td>
				<td>
							<volist name="warehouse_list" id="vo">
								<if condition="$vo['warehouse_code'] eq $detail['inbound_warehouse_code']"><{$vo.name}></if>
							</volist>
				</td>
				<td><{$vs.pro_name}></td>
				<td><{$vs.pro_spec}></td>
				<td><{$vs.source_no}></td>
				<td><{$vs.pro_no}></td>
				<td><{$vs.pro_num_plan}></td>
				<td>
				<volist name="unit_list" id="vo">
									<if condition="$vo['unit_no'] eq $vs['unit1']"><{$vo.unit_name}></if>
								</volist>
				</td>
				<td><{$vs.product_weeks}></td>
				<td><{$vs.product_marks}></td>
				<td><input type="text" class="input-text"  placeholder="账册编码" id="manua_id" name="manua_id"  value="<{$vs.manua_id}>" ></td>
				<td><input type="text" class="input-text"  placeholder="条形码" id="bar_code" name="bar_code"  value="<{$vs.bar_code}>" ></td>
				<td><input type="text" class="input-text"  placeholder="完成数量" id="pro_num" name="pro_num"  value="<{$vs.pro_num}>" ></td>
				<td><input type="text" class="input-text"  placeholder="实际入库数量" id="inbound_num" name="inbound_num"  value="<{$vs.inbound_num}>" ></td>
				<td><input type="text" class="input-text"  placeholder="合格品数量" id="conforming_p_num" name="conforming_p_num"  value="<{$vs.conforming_p_num}>" ></td>
				<td><input type="text" class="input-text"  placeholder="残次品数量" id="nonconforming_p_num" name="nonconforming_p_num"  value="<{$vs.nonconforming_p_num}>" ></td>
				<td><input type="text" class="input-text"  placeholder="报废品数量" id="scrap_one_num" name="scrap_one_num"  value="<{$vs.scrap_one_num}>" ></td>
				<td><input type="text" class="input-text"  placeholder="入库成本单价" id="inbound_price" name="inbound_price"  value="<{$vs.inbound_price}>" ></td>
				<td><input type="text" class="input-text"  placeholder="销售单价(含税)" id="sell_price" name="sell_price"  value="<{$vs.sell_price}>" ></td>
				<td><input type="text" class="input-text"  placeholder="出厂价" id="factory_price" name="factory_price"  value="<{$vs.factory_price}>" ></td>
				<td><input type="input-text" name="overdue_time" onfocus="WdatePicker({el:$dp.$('d12')})" id="overdue_time" class="input-text Wdate" style="width:120px;" value="<{$vs.overdue_time|date='Y-m-d',###}>"  placeholder="过期时间"></td>
				<td><input type="input-text" name="factory_time" onfocus="WdatePicker({el:$dp.$('d12')})" id="factory_time" class="input-text Wdate" style="width:120px;" value="<{$vs.factory_time|date='Y-m-d',###}>"  placeholder="生产时间"></td>
				<td><{$vs.mark}></td>
			</tr>
			</volist>
		</tbody>
	</table>
	<input type="button" class="btn btn-primary radius mt" id="pedit" value="修改">
	<table class="table table-border table-bordered table-hover table-bg" style="margin-top:20px;">
		<thead>
			<tr>
				<th scope="col" colspan="13">原料列表</th>
			</tr>
			<tr class="text-c">
				<th width="40">ID</th>
				<th width="40">原料编码</th>
				<th width="40">原料名称</th>
				<th width="100">账册编码</th>
				<th width="40">料号</th>
				<th width="40">规格</th>
				<th width="40">币制</th>
				<th width="40">单价</th>
				<th width="40">主单位</th>
				<th width="40">主单位数量</th>
				<th width="40">总金额</th>
				<th width="40">损耗数量</th>
				<th width="40">边角料数量</th>
			</tr>
		</thead>
		<tbody>
			<volist name="list" id="vo">
			<tr class="text-c">
			 <input  name='gid' type="hidden" style="width:80px;" value="<{$vo['id']}>"/>
				<td><{$vo.id}></td>
				<td>
					<input  name='goods_no' type="hidden" style="width:80px;" value="<{$vo['goods_no']}>"/>
				<{$vo.goods_no}>
				</td>
				<td><{$vo.goods_name}></td>
				<td><{$vo.manua_id}></td>
				<td><{$vo.source_no}></td>
				<td>
					 <{$vo['goods_spec']}>
				</td>
				<td><{$vo.currency_name}></td>
				<td>
					 <{:round($vo['price'],2)}>
				</td>
				<td>
					 <{$vo.unit1_name}>
				</td>
				<td>
					<{$vo['weight']}>
				</td>
				<td>
					<{$vo['total_price']}>
				</td>
				<td>
					<input  name='material_weight' type="text" style="width:80px;" value="<{$vo['material_weight']}>"/>
				</td>
				<td>
					<input  name='scrap_weight' type="text" style="width:80px;" value="<{$vo['scrap_weight']}>"/>
				</td>
			</tr>
			</volist>
		</tbody>
	</table>
	<table class="table table-border table-bordered table-hover table-bg" style="margin-top:20px;">
		<thead>
			<tr>
				<th scope="col" colspan="13">辅料列表</th>
			</tr>
			<tr class="text-c">
				<th width="40">ID</th>
				<th width="40">辅料编码</th>
				<th width="40">辅料名称</th>
				<th width="100">账册编码</th>
				<th width="40">料号</th>
				<th width="40">规格</th>
				<th width="40">币制</th>
				<th width="40">单价</th>
				<th width="40">主单位</th>
				<th width="40">主单位数量</th>
				<th width="40">总金额</th>
				<th width="40">损耗数量</th>
				<th width="40">边角料数量</th>
			</tr>
		</thead>
		<tbody>
			<volist name="list_f" id="vo">
			<tr class="text-c">
			 <input  name='gid' type="hidden" style="width:80px;" value="<{$vo['id']}>"/>
				<td><{$vo.id}></td>
				<td>
				<{$vo.goods_no}>
				</td>
				<td><{$vo.goods_name}></td>
				<td><{$vo.manua_id}></td>
				<td><{$vo.source_no}></td>
				<td>
					 <{$vo['goods_spec']}>
				</td>
				<td><{$vo.currency_name}></td>
				<td>
					 <{:round($vo['price'],2)}>
				</td>
				<td>
					 <{$vo.unit1_name}>
				</td>
				<td>
					<{$vo['weight']}>
				</td>
				<td>
					 <{$vo.total_price}>
				</td>
				<td>
					<input  name='material_weight' type="text" style="width:80px;" value="<{$vo['material_weight']}>"/>
				</td>
				<td>
					<input  name='scrap_weight' type="text" style="width:80px;" value="<{$vo['scrap_weight']}>"/>
				</td>
			</tr>
			</volist>
		</tbody>
	</table>
	<input type="button" class="btn btn-primary radius mt" id="bedit" value="保存">
<div class="pages">
<{$page}>
</div>
</div>
<include file="Public/footer" />
<include file="Public/footer_js" />
<script type="text/javascript">
    $(function(){
		/*保存计划入库单数据*/
        $("#pedit").click(function(){
		if($('input').val()==''){
			layer.msg('数据不能为空');
			return false;
		}
		for(var i=0;i<$('input[name=bar_code]').length;i++){
		if(i==0){
			var list_id=$('input[name=list_id]').eq(i).val();
			var factory_price=$('input[name=factory_price]').eq(i).val();
			var sell_price=$('input[name=sell_price]').eq(i).val();
			var inbound_price=$('input[name=inbound_price]').eq(i).val();
			var pro_num=$('input[name=pro_num]').eq(i).val();
			var scrap_one_num=$('input[name=scrap_one_num]').eq(i).val();
			var nonconforming_p_num=$('input[name=nonconforming_p_num]').eq(i).val();
			var conforming_p_num=$('input[name=conforming_p_num]').eq(i).val();
			var inbound_num=$('input[name=inbound_num]').eq(i).val();
			var bar_code=$('input[name=bar_code]').eq(i).val();
			var manua_id=$('input[name=manua_id]').eq(i).val();
			
			var overdue_time=$('input[name=overdue_time]').eq(i).val();
			var factory_time=$('input[name=factory_time]').eq(i).val();
			var mark=$('input[name=mark]').eq(i).val();
			$.ajax({
                type: 'POST',
                data: {
						id:<{:I('id')}>,
						factory_price: factory_price,
						sell_price: sell_price,
						inbound_price: inbound_price,
						pro_num: pro_num,
						overdue_time: overdue_time,
						factory_time: factory_time,
						scrap_one_num: scrap_one_num,
						nonconforming_p_num: nonconforming_p_num,
						conforming_p_num:conforming_p_num,
						inbound_num: inbound_num,
						bar_code:bar_code,
						manua_id:manua_id,
						mark:mark,
						for_id:1
					  },
                url: "<{:U('edt_change')}>",
                success:function(data){
                    layer.msg(data.info,function(){
						if(data.status==0){
							return false;
						}
					});
                }
            })
		}else{
			var list_id=$('input[name=list_id]').eq(i).val();
			var factory_price=$('input[name=factory_price]').eq(i).val();
			var sell_price=$('input[name=sell_price]').eq(i).val();
			var inbound_price=$('input[name=inbound_price]').eq(i).val();
			var pro_num=$('input[name=pro_num]').eq(i).val();
			var scrap_one_num=$('input[name=scrap_one_num]').eq(i).val();
			var nonconforming_p_num=$('input[name=nonconforming_p_num]').eq(i).val();
			var conforming_p_num=$('input[name=conforming_p_num]').eq(i).val();
			var inbound_num=$('input[name=inbound_num]').eq(i).val();
			var bar_code=$('input[name=bar_code]').eq(i).val();
			var manua_id=$('input[name=manua_id]').eq(i).val();
			var overdue_time=$('input[name=overdue_time]').eq(i).val();
			var factory_time=$('input[name=factory_time]').eq(i).val();
			var mark=$('input[name=mark]').eq(i).val();
			
			$.ajax({
                type: 'POST',
                data: {
						id:list_id,
						factory_price: factory_price,
						sell_price: sell_price,
						inbound_price: inbound_price,
						pro_num: pro_num,
						overdue_time: overdue_time,
						factory_time: factory_time,
						scrap_one_num: scrap_one_num,
						nonconforming_p_num: nonconforming_p_num,
						conforming_p_num:conforming_p_num,
						inbound_num: inbound_num,
						bar_code:bar_code,
						manua_id:manua_id,
						mark:mark,
						for_id:2
					  },
                url: "<{:U('edt_change')}>",
                success:function(data){
                    layer.msg(data.info,function(){
						if(data.status==0){
							return false;
						}
					});
                }
            }) 
		}
		}
        });
		$("#bedit").click(function(){
			var count=$('input[name=material_weight]').length;
			var gid=$('input[name=gid]');
			var material_weight=$('input[name=material_weight]');
			var scrap_weight=$('input[name=scrap_weight]');
			if(count<1){
				layer.msg('没有添加原料');
				return false;
			}
			var str='';
			for(var i=0;i<count;i++){
				if(i==0){
					str=str+gid.eq(i).val()+":"+material_weight.eq(i).val()+":"+scrap_weight.eq(i).val();
				}else{
					str=str+","+gid.eq(i).val()+":"+material_weight.eq(i).val()+":"+scrap_weight.eq(i).val();
				}
			}
			
			$.ajax({
                type: 'POST',
                data: {
						id:<{:I('id')}>,
						str:str
					  },
                url: "<{:U('edt_change_p')}>",
                success:function(data){
                    layer.msg(data.info,function(){
						if(data.status==0){
							return false;
						}else{
							self.window.location.href =self.window.location.href;
						}
					});
                }
            })
        });
    })
</script>
</body>
</html>
</html>